package com.ruoyi.tongyan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.tongyan.domain.TAchievementActivity;
import com.ruoyi.tongyan.service.ITAchievementActivityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 科研活动记录Controller
 * 
 * @author ruoyi
 * @date 2025-04-21
 */
@RestController
@RequestMapping("/tongyan/activity")
public class TAchievementActivityController extends BaseController
{
    @Autowired
    private ITAchievementActivityService tAchievementActivityService;

    /**
     * 查询科研活动记录列表
     */
    @PreAuthorize("@ss.hasPermi('tongyan:activity:list')")
    @GetMapping("/list")
    public TableDataInfo list(TAchievementActivity tAchievementActivity)
    {
        startPage();
        List<TAchievementActivity> list = tAchievementActivityService.selectTAchievementActivityList(tAchievementActivity);
        return getDataTable(list);
    }

    /**
     * 导出科研活动记录列表
     */
    @PreAuthorize("@ss.hasPermi('tongyan:activity:export')")
    @Log(title = "科研活动记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TAchievementActivity tAchievementActivity)
    {
        List<TAchievementActivity> list = tAchievementActivityService.selectTAchievementActivityList(tAchievementActivity);
        ExcelUtil<TAchievementActivity> util = new ExcelUtil<TAchievementActivity>(TAchievementActivity.class);
        util.exportExcel(response, list, "科研活动记录数据");
    }

    /**
     * 获取科研活动记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('tongyan:activity:query')")
    @GetMapping(value = "/{achivementId}")
    public AjaxResult getInfo(@PathVariable("achivementId") Long achivementId)
    {
        return success(tAchievementActivityService.selectTAchievementActivityByAchivementId(achivementId));
    }

    /**
     * 新增科研活动记录
     */
    @PreAuthorize("@ss.hasPermi('tongyan:activity:add')")
    @Log(title = "科研活动记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TAchievementActivity tAchievementActivity)
    {
        return toAjax(tAchievementActivityService.insertTAchievementActivity(tAchievementActivity));
    }

    /**
     * 修改科研活动记录
     */
    @PreAuthorize("@ss.hasPermi('tongyan:activity:edit')")
    @Log(title = "科研活动记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TAchievementActivity tAchievementActivity)
    {
        return toAjax(tAchievementActivityService.updateTAchievementActivity(tAchievementActivity));
    }

    /**
     * 删除科研活动记录
     */
    @PreAuthorize("@ss.hasPermi('tongyan:activity:remove')")
    @Log(title = "科研活动记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{achivementIds}")
    public AjaxResult remove(@PathVariable Long[] achivementIds)
    {
        return toAjax(tAchievementActivityService.deleteTAchievementActivityByAchivementIds(achivementIds));
    }
}
